import {
    _decorator, Component, director, Node, ProgressBar, ResolutionPolicy, resources,
    view,
} from 'cc';
import {userInfo} from '../script/user-info';

const {ccclass, property} = _decorator;

@ccclass('boot')
export class boot extends Component {

    @property(ProgressBar)
    progressBar: ProgressBar = null!;

    @property(Node)
    startBtn: Node = null!;

    @property(Node)
    mask!: Node

    start() {
        this.startBtn.active = false;
        view.setResolutionPolicy(ResolutionPolicy.SHOW_ALL);
        userInfo.start();
        resources.loadDir("/",
            (finished: number, total: number) => {
                this.progressBar.progress = finished / total;
            },
            () => {
                this.progressBar.node.active = false;
                this.startBtn.active = true;
            })
        this.startBtn.on(Node.EventType.TOUCH_END, async () => {
            this.mask.active = true
            director.loadScene("lobby")
        }, this)
    }


    update(deltaTime: number) {

    }
}


